﻿using UnityEngine;

public class LoginClass : BaseMono
{
	public UserData UserData;
	public ChatData ChatData;

	public override void onAwake() {
		base.onAwake();
		base.Init();
	}

	public override void onUpdate() {
		base.onUpdate();
		if (Input.GetKeyDown(KeyCode.L))
		{
			Login();
		}
		if (Input.GetKeyDown(KeyCode.C))
		{
			Chat();
		}
	}

	public void Login()
	{
		SocketMgr.Ins.Req(new SendData(MethodDef.Login, JsonUtility.ToJson(UserData), ReqType.NeedWait));
	}

	public void Chat()
	{
		if (ChatData.RID.Equals(ChatData.WID)) {
			MyLog.LogWarning("Send To Self " + JsonUtility.ToJson(ChatData));
		}

		SocketMgr.Ins.Req(new SendData(MethodDef.Chat, JsonUtility.ToJson(ChatData)));
	}
}
